<template>
	<view class="reseller">
		<view class="top">
			<view class="num" style="margin-left: 30px;">
				<view>今日收益</view>
				<view class="txc">{{ yesterdayMoney }}</view>
			</view>
			<view class="num1" style="">
				<view>当前佣金</view>
				<view style="font-size: 40px;">{{ rewardSumMoney }}</view>
			</view>
			<view class="num" style="margin-right: 30px;">
				<view>累计已提</view>
				<view>{{ cashSumMoney }}</view>
			</view>
			<view class="tixian" @click="jump_cash">
				<view class="btn" style="font-size: 16px;">立即提现</view>
			</view>
			<view class="jilu">
				<navigator hover-class="none" url="/pages/user/record/record">
					<view class="jl">提现记录 ></view>
				</navigator>
			</view>
		</view>
		<view class="icon">
			<view class="ico" v-for="(item, index) of list" :key="index">
				<navigator hover-class="none" :url="item.url">
					<view class="tubiao">
						<image class="img" :src="item.img"></image>
					</view>
					<view class="tt">
						<view class="text">{{ item.title }}</view>
					</view>
				</navigator>
			</view>
		</view>
		<view class="kong"></view>
	</view>
</template>

<script>
	import {
		mapActions
	} from 'vuex';
	export default {
		data() {
			return {
				list: [{
						title: '推广名片',
						img: require('@/imgs/mp.png'),
						url: '/pages/user/spread/spread'
					},
					{
						title: '推广人统计',
						img: require('@/imgs/tj.png'),
						url: '/pages/user/agent/agent'
					},
					{
						title: '佣金明细',
						img: require('@/imgs/q.png'),
						url: '/pages/user/mingxi/mingxi'
					},
					{
						title: '推广排名',
						img: require('@/imgs/dd.png'),
						url: '/pages/user/sort/sort'
					}
				],
				rewardSumMoney: 0,
				yesterdayMoney: 0,
				cashSumMoney: 0
			};
		},
		onLoad() {
			uni.showLoading({
				mask: true
			});
			this.rewardSummary().then(res => {
				console.log('summary', res)
				this.rewardSumMoney = res.data.rewardSumMoney;
				this.yesterdayMoney = res.data.yesterdayMoney;
				this.cashSumMoney = res.data.cashSumMoney;
				uni.hideLoading();
			});
		},
		onShareAppMessage(res) {
			let referrer = uni.getStorageSync('referrer');
			console.log('referrer', referrer);
			if (referrer) {
				return {
					title: '恒鲜惠美食在线',
					path: '/pages/menu/menu?referrer=' + referrer,
					imageUrl: require('static/images/menu/banner.jpeg')
				}
			}
		},
		methods: {
			...mapActions(['rewardSummary']),
			jump_cash() {
				uni.navigateTo({
					url: '/pages/user/cash/cash'
				});
			}
		}
	};
</script>

<style lang="less">
	page {
		background-color: #f5f5f5;
	}

	.reseller {
		background-color: #f5f5f5;
		min-height: 100vh;
		font-size: 14px;

		.top {
			color: #ffffff;
			display: flex;
			justify-content: space-between;
			position: relative;
			width: 100%;
			height: 250px;
			background-color: #dd524d;
			background: linear-gradient(top, #4ec28e, #1c9c63);

			.title {
				background-color: #ffffff;
			}

			.num {
				font-size: 15px;
				line-height: 25px;
				text-align: center;
				margin-top: 33%;
				width: 33%;
			}

			.num1 {
				margin-top: 10%;
				text-align: center;
				width: 33%;
			}
		}

		.jilu {
			font-size: 15px;
			position: absolute;
			left: 75%;
			top: 20%;
		}

		.tixian {
			display: flex;
			justify-content: center;
			background-color: #f5f5f5;
			width: 55%;
			height: 60px;
			border-radius: 60px;
			position: absolute;
			bottom: -30px;
			left: 23%;

			.btn {
				margin-top: 7%;
				text-align: center;
				width: 85%;
				background-color: #1c9c63;
				height: 40px;
				border: none;
				border-radius: 50px;
				line-height: 40px;
				color: #ffffff;
			}
		}

		.icon {
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;

			margin-left: 3%;
			margin-right: 3%;
			margin-top: 10%;

			.ico {
				border-radius: 10px;
				border: 1px solid #c0c0c0;
				width: 49%;
				height: 100px;
				margin-top: 10px;
				display: flex;
				border: none;
				font-size: 15px;
				flex-direction: column;
				background-color: #ffffff;

				.img {
					width: 32px;
					height: 32px;
				}

				.tubiao {
					margin-top: 20px;
					text-align: center;
				}

				.text {
					color: #8f8f94;
					padding-top: 5px;
					text-align: center;
				}
			}
		}

		.kong {
			height: 100px;
		}
	}
</style>
